// 柯里化案例
// ''.match(/\s+/g);
// ''.match(/\d+/g);
const _ = require('lodash');

// const match =  _.curry(function (reg, str) {
//     return str.match(reg);
// })

const match = _.curry((reg, str) => str.match(reg));

const haveSpace = match(/\s+/g);
const haveNumber = match(/\d+/g);

// const filter = _.curry(function (fn, array) {
//     return array.filter(fn);
// })

const filter = _.curry((fn, array) => array.filter(fn));

const findSpace = filter(haveSpace);
const findNumber = filter(haveNumber);

console.log(haveSpace('Hello World'));
console.log(haveNumber('1234avde'));

console.log(filter(haveSpace)(['John Connor', 'John_Donne']));

console.log(findSpace(['John Connor', 'John_Donne']));
console.log(findNumber(['John1 Connor', 'John_Donne']));
